//
//  MapView.swift
//  SwiftUi
//
//  Created by xm on 29/08/2025.
//

import SwiftUI
import MapKit

struct MapView: UIViewRepresentable {
    
    let center:CLLocationCoordinate2D
    
    func makeUIView(context: Context) -> MKMapView {
        MKMapView()
    }
    
    func updateUIView(_ uiView: MKMapView, context: Context) {
//        let center = CLLocationCoordinate2D(latitude: 39.9087243, longitude: 116.3952859)
        let span = MKCoordinateSpan(latitudeDelta: 0.02, longitudeDelta: 0.02)
        uiView.setRegion(MKCoordinateRegion(center:center, span:span),animated: true)
        uiView.mapType = .standard

    }
}

#Preview {
    MapView(center: CLLocationCoordinate2D(latitude: 39.9087243, longitude: 116.3952859))
}
